---
title: Configuration.connectHTTPTunnel()
api: Configuration.connectHTTPTunnel
---

## Description

<Summary/>

<FilterDiagram
  name="connectHTTPTunnel"
  input="Data"
  output="Data"
  subInput="Message + Data"
  subOutput="Message + Data"
  subType="link"
/>

A _connectHTTPTunnel_ filter pumps its input _Data_ stream into a newly created sub-pipeline, prepended by an HTTP [CONNECT](https://developer.mozilla.org/docs/Web/HTTP/Methods/CONNECT) request _Message_. Its output is the _Data_ stream coming out of the sub-pipeline, with the leading HTTP _Message_ in response to the _CONNECT_ request removed.

## Syntax

``` js
pipy()
  .pipeline()
  .connectHTTPTunnel(target).to(
    subPipelineLayout
  )

pipy()
  .pipeline()
  .connectHTTPTunnel(
    () => getTarget()
  ).to(
    subPipelineLayout
  )
```

## Parameters

<Parameters/>

## Example

``` js
pipy()

  .listen(8443)
  .connectHTTPTunnel(
     'example.com:443', // the target address we intend to connect to
  ).to(
    $=>$.muxHTTP().to( // encode CONNECT requests into an HTTP stream
      $=>$.connect(
        'localhost:8000' // suppose we have a local HTTP proxy on port 8000
      )
    )
  )
```

## See Also

* [Configuration](/reference/api/Configuration)
* [acceptHTTPTunnel()](/reference/api/Configuration/acceptHTTPTunnel)
